package com.hudson.plugin.server.hibernateDB.domain.dao;

import com.hudson.plugin.server.hibernateDB.internal.domain.entity.BuildRelationsEntity;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: Richard
 * Date: 5/29/11
 * Time: 10:37 PM
 * To change this template use File | Settings | File Templates.
 */
public interface BuildRelationsDAOInterface {
    // property constants
    String PARENT_ID = "parentId";
    String CHILD_ID = "childId";

    @Transactional(readOnly = false, propagation = Propagation.REQUIRED)
    void save(BuildRelationsEntity transientInstance);

    @Transactional(readOnly = false, propagation = Propagation.REQUIRED)
    void delete(BuildRelationsEntity persistentInstance);

    BuildRelationsEntity findById(Integer id);

    List findByProperty(String propertyName, Object value);

    List findByParentId(Object parentId);

    List findByChildId(Object childId);

    List findAll();

    @Transactional(readOnly = false, propagation = Propagation.REQUIRED)
    BuildRelationsEntity merge(BuildRelationsEntity detachedInstance);

    @Transactional(readOnly = false, propagation = Propagation.REQUIRED)
    void attachDirty(BuildRelationsEntity instance);

    @Transactional(readOnly = false, propagation = Propagation.REQUIRED)
    void attachClean(BuildRelationsEntity instance);

    List<Integer> findParentIdByChildId(Integer childId);
}
